/**
 * webpack配置文件
 * created by xq on 2018/10/16
 */

 const webpack = require('webpack')
 const path = require('path')
 const HtmlWebpackPlugin = require('html-webpack-plugin')

 module.exports = {
   // 开发模式
   mode: 'development',
   entry: {
     app: path.resolve(__dirname, 'src/index.js')
   },
   output: {
     path: path.resolve(__dirname, '/dist/js'),
     filename: '[name].js'
   },
   module: {
     rules: [
       {
         test: /\.js$/,
         exclude: /node_modules/,
         include: path.resolve(__dirname, './src'),
         use: {
           loader: 'babel-loader'
         }
       }
     ]
   },
   plugins: [
     new HtmlWebpackPlugin({
       template: path.resolve(__dirname, 'src/index.html'),
       filename: 'index.html',
       hash: true
     }),
     new webpack.HotModuleReplacementPlugin()
   ],
   devServer: {
     host: '127.0.0.1',
     port: 8888,
     open: true,
     inline: true,
     hot: true
   }
 }